<?php

use think\facade\Route;

//全局路由变量
Route::pattern([
    'id'    => '\d+',
]);

Route::group(function (){
    // 登录退出
    Route::post('auth/login', 'AuthController@login');
    Route::group(function (){
        Route::post('auth/logout', 'AuthController@logout');
        Route::get('auth/me', 'AuthController@me');
        // 游戏管理
        Route::get('games', 'GameController@index');        // 查询
        Route::post('game/create', 'GameController@create');       // 新增
        Route::get('game/:id/show', 'GameController@show');      // 展示
        Route::put('game/:id/update', 'GameController@update');    // 修改
        Route::delete('game/:id/delete', 'GameController@delete'); // 删除
        Route::post('game/cache', 'GameController@cache');  // 缓存游戏
        // 提现管理
        Route::get('withdraws', 'WithdrawController@index');        // 查询
        // Route::post('withdraw', 'WithdrawController@create');       // 新增
        Route::get('withdraw/:id', 'WithdrawController@show');      // 展示
        // Route::put('withdraw/:id', 'WithdrawController@update');    // 修改
        Route::delete('withdraw/:id', 'WithdrawController@delete'); // 删除
        Route::put('withdraw/:id/audit', 'WithdrawController@audit');   //提现审核
        Route::get('withdraw/user/:id/statistics', 'WithdrawController@userStatistics');   //用户钱包数据
        // 管理员相关
        Route::get('admins', 'AdminController@index');          // 查询
        Route::post('admin', 'AdminController@create');         // 新增
        Route::get('admin/:id', 'AdminController@show');        // 展示
        Route::put('admin/:id', 'AdminController@update');      // 更新
        Route::delete('admin/:id', 'AdminController@delete');   // 删除
    })->middleware([
        \thans\jwt\middleware\JWTAuthAndRefresh::class,
        \app\admin\middlewares\CheckJwt::class
    ]);
})->prefix('\app\admin\controllers\\')->allowCrossDomain();
